load("//bazel:cc_binary_with_flags.bzl", "cc_binary_with_flags")
load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_cc_library")

licenses(["notice"])

exports_files_legacy()

skia_cc_library(
    name = "legacy_skottie",
    srcs = [
        "//modules/skottie/src:srcs",
        "//src/utils:json_hdrs",
        "//src/utils:json_srcs",
    ],
    hdrs = ["//modules/skottie/include:hdrs"],
    visibility = ["//:__subpackages__"],
    deps = [
        "//:skia_internal",
        "//modules/skresources:legacy_skresources",
        "//modules/sksg:legacy_sksg",
        "//modules/skshaper:legacy_skshaper",
        "//modules/skunicode:legacy_skunicode",
    ],
)

skia_cc_library(
    name = "utils",
    srcs = ["//modules/skottie/utils:srcs"],
    hdrs = ["//modules/skottie/utils:hdrs"],
    visibility = ["//:__subpackages__"],
    deps = [
        ":legacy_skottie",
        "//tools/skui",
    ],
)

cc_binary_with_flags(
    name = "skottie_tool_cpu",
    testonly = True,
    srcs = [
        "//modules/skottie/src:skottie_tool",
        "//tools/flags",
    ],
    defines = ["CPU_ONLY"],
    set_flags = {
        "include_fontmgr": ["custom_empty_fontmgr"],
        "include_decoder": [
            "jpeg_decode_codec",
            "png_decode_codec",
            "webp_decode_codec",
        ],
        "use_harfbuzz": ["True"],
        "use_icu": ["True"],
    },
    deps = [
        ":legacy_skottie",
        ":utils",
    ],
)

cc_binary_with_flags(
    name = "skottie_tool_gpu",
    testonly = True,
    srcs = [
        "//modules/skottie/src:skottie_tool",
        "//tools/flags",
    ],
    defines = ["GPU_ONLY"],
    set_flags = {
        "enable_gpu_test_utils": ["True"],
        "include_fontmgr": ["custom_empty_fontmgr"],
        "gpu_backend": ["gl_ganesh"],
        "include_decoder": [
            "jpeg_decode_codec",
            "png_decode_codec",
            "webp_decode_codec",
        ],
        "use_harfbuzz": ["True"],
        "use_icu": ["True"],
        "with_gl_standard": ["gl_standard"],
    },
    deps = [
        ":legacy_skottie",
        ":utils",
        "//tools/gpu:utils",
    ],
)
